from rest_framework.serializers import ModelSerializer

from home.models import NavModel, BannerModel, CategoryModel


class NavSer(ModelSerializer):
    class Meta:
        model = NavModel
        fields = '__all__'

class BannerSer(ModelSerializer):
    class Meta:
        model = BannerModel
        fields = '__all__'

class CategoryChild(ModelSerializer):
    class Meta:
        model = CategoryModel
        fields = ['id','catename']
# 首页序列化器
class CategorySer(ModelSerializer):
    children=CategoryChild(many=True)
    class Meta:
        model = CategoryModel
        fields = '__all__'